
from lib.tools.logger import Logger
from abc import ABCMeta, abstractmethod


class RedisAbstract(object):

    __metaclass__ = ABCMeta

    def __init__(self, logger=None):
        if not logger:
            logger = Logger()
        self.logger = logger

    @abstractmethod
    def ping(self):
        pass

    @abstractmethod
    def size(self):
        pass

    @abstractmethod
    def ttl(self, name):
        pass

    @abstractmethod
    def expire(self, name, time):
        pass

    @abstractmethod
    def persist(self, name):
        pass

    @abstractmethod
    def type(self, name):
        pass

    @abstractmethod
    def rename(self, name, new_name):
        pass

    @abstractmethod
    def renamenx(self, name, new_name):
        pass

    @abstractmethod
    def keys(self, pattern='*'):
        pass

    @abstractmethod
    def scan(self, cursor=0, match=None, count=None):
        pass

    @abstractmethod
    def exists(self, name):
        pass

    @abstractmethod
    def get(self, name):
        pass

    @abstractmethod
    def set(self, name, value):
        pass

    @abstractmethod
    def getset(self, name, value):
        pass

    @abstractmethod
    def delete(self, name):
        pass

    @abstractmethod
    def hexists(self, name, key):
        pass

    @abstractmethod
    def hall(self, name):
        pass

    @abstractmethod
    def hget(self, name, key):
        pass

    @abstractmethod
    def hset(self, name, key, value):
        pass

    @abstractmethod
    def hmget(self, name, keys, *args):
        pass

    @abstractmethod
    def hmset(self, name, dict):
        pass

    @abstractmethod
    def hdel(self, name, key):
        pass

    # @abstractmethod
    # def close(self, name, key):
    #     pass